home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_StoredProcedures_JScript.asp < prev    next >
Encoding:
Text File  |  1999-06-03  |  1.5 KB  |  65 lines

  1. <%     @ LANGUAGE="JScript"         %>
  2.  
  3. <!--METADATA TYPE="typelib" 
  4. uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
  5.  
  6. <%
  7.     // This example calls the ByRoyalty stored procedure 
  8.     // installed with the PUBS database with Microsoft SQL Server.
  9.  
  10.     // This sample assumes that SQL Server is running on the local machine
  11. %>
  12.  
  13.  
  14. <HTML>
  15.     <HEAD>
  16.         <TITLE>Using Stored Procedures</TITLE>
  17.     </HEAD>
  18.  
  19.     <BODY bgcolor="white" topmargin="10" leftmargin="10">
  20.         
  21.         <!-- Display Header -->
  22.  
  23.         <font size="4" face="Arial, Helvetica">
  24.         <b>Using Stored Procedures</b></font><p>   
  25.  
  26.         <%
  27.             var oConn;        
  28.             var oCmd;        
  29.             var oRs;
  30.             var strConn;    
  31.  
  32.             oConn = Server.CreateObject("ADODB.Connection");
  33.             oCmd = Server.CreateObject("ADODB.Command");
  34.  
  35.             
  36.             // Open ADO Connection using account "sa"
  37.             // and blank password
  38.             
  39.             strConn="Provider=SQLOLEDB;User ID=sa;Initial Catalog=pubs;Data Source=" + Request.ServerVariables("SERVER_NAME");
  40.             oConn.Open(strConn);
  41.             oCmd.ActiveConnection = oConn;
  42.  
  43.  
  44.             // Setup Call to Stored Procedure and append parameters
  45.  
  46.             oCmd.CommandText = "{call byroyalty(?)}";
  47.             oCmd.Parameters.Append(oCmd.CreateParameter("@Percentage", adInteger, adParamInput));
  48.  
  49.  
  50.             // Assign value to input parameter
  51.     
  52.             oCmd("@Percentage") = 75;        
  53.             
  54.             
  55.             // Fire the Stored Proc and assign resulting recordset
  56.             // to our previously created object variable
  57.             
  58.             oRs = oCmd.Execute();            
  59.         %>
  60.  
  61.         Author ID = <% Response.Write(oRs("au_id")) %><BR>
  62.  
  63.     </BODY>
  64. </HTML>
  65.